package im.vinci.server.headphone.controller;

import im.vinci.server.headphone.domain.BarrageText;
import im.vinci.server.headphone.domain.LanguageType;
import im.vinci.server.headphone.domain.VisualCategory;
import im.vinci.server.headphone.service.VisualService;
import im.vinci.server.security.ApiSecurityLabel;
import im.vinci.server.utils.apiresp.ResultObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * Created by mingjie on 17/3/6.
 */
@RestController
@RequestMapping(value = "/vinci/headphone/visual", produces = "application/json;charset=UTF-8")
public class VisualController {

    @Autowired
    private VisualService visualService;

    @RequestMapping(value = "/data", method = RequestMethod.GET)
    @ApiSecurityLabel
    public ResultObject<List<VisualCategory>> getVisualData(@RequestParam(value = "language", defaultValue = "cn") String language, @RequestParam(value = "deviceId", defaultValue = "") String deviceId) {
        List<VisualCategory> list = visualService.getVisualData(LanguageType.getLanguageType(language), deviceId);
        return new ResultObject<>(list);
    }

    @RequestMapping(value = "/barrage", method = RequestMethod.GET)
    @ApiSecurityLabel
    public ResultObject<List<BarrageText>> getBarrage(@RequestParam(value = "language", defaultValue = "cn") String language) {
        List<BarrageText> list = visualService.getBarrageData(LanguageType.getLanguageType(language));
        return new ResultObject<>(list);
    }
}
